using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Windy.OpenLink.Names;

namespace Windy.OpenLink.Names
{
    [Serializable]
    public class NameException : ApplicationException
    {
        public NameException() { }
        public NameException(string message) : base(message) { }
        public NameException(string message, Exception inner) : base(message, inner) { }
        protected NameException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context)
            : base(info, context) { }

        public enum ExceptionReason
        {
            Custom = 0,
            InvalidNodePrimaryName,
            InvalidNodeExtensionName,
            InvalidNodeName,
            InvalidName,
        }

        public static NameException CreateKnownException(ExceptionReason reason)
        {
            switch (reason)
            {
                case ExceptionReason.InvalidNodePrimaryName:
                    return new NameException("Invalid Node Primary Name.");
                case ExceptionReason.InvalidNodeExtensionName:
                    return new NameException("Invalid Node Extension Name.");
                case ExceptionReason.InvalidNodeName:
                    return new NameException("Invalid Node Name.");
                case ExceptionReason.InvalidName:
                    return new NameException("Invalid Name.");
                case ExceptionReason.Custom:
                default:
                    throw new NotSupportedException("Not supported name exception reason value.");
            }
        }
    }
}
